package com.ds.lens.data.common.document;

import lombok.Builder;
import lombok.Data;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.Document;

import java.util.List;
import java.util.Map;

/**
 * @author WeiShaoying
 * @date 2019/11/11 下午4:54
 */
@Document(indexName = "event", type = "event", createIndex = false)
@Data
public class Event {
    @Id
    private String id;
    private String uid;
    private Integer detectionMethod;
    private String ticket;
    private String name;
    private String groupbyKey; //ticket + monitorid + version
    private Long monitorId;
    private Long monitorCreateTime;
    private Long pastDataStartTime;
    private Map<String, Object> threshold;
    private Long version;
    private String state;
    private Boolean renotify;
    private List<String> tags;
    private String expression;
    private Triggered triggered;
    private Notify notify;
    private Long timeStamp;
    private Long interval;
    private Long queryDelayTime;
    private Long retriveDuration;
    private String metricName;
    private Integer metricAggr;
    private Map<String, Object> scope;
    private Long integrationId;
    private Map<String, Object> metricFilter;
    private List<String> metricBy;
    private Long appId;

    public Event(){}

    @Builder
    public Event(String uid,
                 Integer detectionMethod,
                 String ticket,
                 String name,
                 Long monitorId,
                 Long monitorCreateTime,
                 Long pastDataStartTime,
                 Map<String, Object> threshold,
                 Long version,
                 String state,
                 Boolean renotify,
                 List<String> tags,
                 String expression,
                 Triggered triggered,
                 Notify notify,
                 Long timeStamp,
                 Long interval,
                 Long queryDelayTime,
                 Long retriveDuration,
                 String metricName,
                 Integer metricAggr,
                 Map<String, Object> scope,
                 Long integrationId,
                 Map<String, Object> metricFilter,
                 List<String> metricBy,
                 Long appId
    ) {
        this.id = uid;
        this.uid = uid;
        this.detectionMethod = detectionMethod;
        this.ticket = ticket;
        this.name = name;
        this.monitorId = monitorId;
        this.monitorCreateTime = monitorCreateTime;
        this.pastDataStartTime = pastDataStartTime;
        this.threshold = threshold;
        this.version = version;
        this.state = state;
        this.renotify = renotify;
        this.tags = tags;
        this.expression = expression;
        this.triggered = triggered;
        this.notify = notify;
        this.timeStamp = timeStamp;
        this.interval = interval;
        this.queryDelayTime = queryDelayTime;
        this.retriveDuration = retriveDuration;
        this.metricName = metricName;
        this.metricAggr = metricAggr;
        this.scope = scope;
        this.integrationId = integrationId;
        this.metricFilter = metricFilter;
        this.metricBy = metricBy;
        this.appId = appId;
        this.groupbyKey = ticket + "-" + monitorId + "-" + version;
    }
}
